home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / libsrc / frame.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-13  |  1.3 KB  |  63 lines

  1. /*
  2. ** frame.c
  3. **
  4. ** Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits
  5. ** Redistributed by permission.
  6. */
  7.  
  8. #include "pictor.h"
  9.  
  10. #define HORIZONTAL      0
  11. #define VERTICAL        1
  12. #define TOP_LEFT        2
  13. #define TOP_RIGHT       3
  14. #define BOTTOM_LEFT     4
  15. #define BOTTOM_RIGHT    5
  16.  
  17. /* define default frame characters */
  18. static char fchars[6] = { '\xCD','\xBA','\xC9','\xBB','\xC8','\xBC' };
  19.  
  20.  
  21. /*
  22. ** Sets the frame type using the frame character arguments.
  23. */
  24. void setframe(char horiz,char vert,char tl,char tr,char bl,char br)
  25. {
  26.     fchars[HORIZONTAL] = horiz;
  27.     fchars[VERTICAL] = vert;
  28.     fchars[TOP_LEFT] = tl;
  29.     fchars[TOP_RIGHT] = tr;
  30.     fchars[BOTTOM_LEFT] = bl;
  31.     fchars[BOTTOM_RIGHT] = br;
  32.  
  33. } /* setframe */
  34.  
  35. /*
  36. ** Draws a box using the current frame type.
  37. */
  38. void frame(int top,int left,int height,int width)
  39. {
  40.     int row = top;
  41.  
  42.     /* draw top of frame */
  43.     setvpos(top,left);
  44.     vputc(fchars[TOP_LEFT]);
  45.     vrepc(fchars[HORIZONTAL],width - 2);
  46.     vputc(fchars[TOP_RIGHT]);
  47.  
  48.     /* draw sides */
  49.     for(row = 1;row < height;row++) {
  50.         setvpos(top + row,left);
  51.         vputc(fchars[VERTICAL]);
  52.         setvpos(top + row,left + (width - 1));
  53.         vputc(fchars[VERTICAL]);
  54.     }
  55.  
  56.     /* draw bottom */
  57.     setvpos(top + (height - 1),left);
  58.     vputc(fchars[BOTTOM_LEFT]);
  59.     vrepc(fchars[HORIZONTAL],width - 2);
  60.     vputc(fchars[BOTTOM_RIGHT]);
  61.  
  62. } /* frame */
  63.